/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package NewKFP;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author $alama
 */
@Entity
@Table(name = "factory")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Factory.findAll", query = "SELECT f FROM Factory f"),
    @NamedQuery(name = "Factory.findByIdFactory", query = "SELECT f FROM Factory f WHERE f.idFactory = :idFactory"),
    @NamedQuery(name = "Factory.findByFactoryName", query = "SELECT f FROM Factory f WHERE f.factoryName = :factoryName")})
public class Factory implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "idFactory")
    private Integer idFactory;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "FactoryName")
    private String factoryName;
    @JoinColumn(name = "idcountry", referencedColumnName = "idcountry")
    @ManyToOne
    private Country idcountry;
    @OneToMany(mappedBy = "factoryID")
    private Collection<BillItem> billItemCollection;

    public Factory() {
    }

    public Factory(Integer idFactory) {
        this.idFactory = idFactory;
    }

    public Factory(Integer idFactory, String factoryName) {
        this.idFactory = idFactory;
        this.factoryName = factoryName;
    }

    public Integer getIdFactory() {
        return idFactory;
    }

    public void setIdFactory(Integer idFactory) {
        this.idFactory = idFactory;
    }

    public String getFactoryName() {
        return factoryName;
    }

    public void setFactoryName(String factoryName) {
        this.factoryName = factoryName;
    }

    public Country getIdcountry() {
        return idcountry;
    }

    public void setIdcountry(Country idcountry) {
        this.idcountry = idcountry;
    }

    @XmlTransient
    public Collection<BillItem> getBillItemCollection() {
        return billItemCollection;
    }

    public void setBillItemCollection(Collection<BillItem> billItemCollection) {
        this.billItemCollection = billItemCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idFactory != null ? idFactory.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Factory)) {
            return false;
        }
        Factory other = (Factory) object;
        if ((this.idFactory == null && other.idFactory != null) || (this.idFactory != null && !this.idFactory.equals(other.idFactory))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "NewKFP.Factory[ idFactory=" + idFactory + " ]";
    }
    
}
